package com.mall.orders.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.model.domain.OmsOrderReturnReason;
import com.mall.model.vo.CommonPage;
import com.mall.orders.mapper.OmsOrderReturnReasonMapper;
import com.mall.orders.service.OmsOrderReturnReasonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 退货原因表(OmsOrderReturnReason)表服务实现类
 *
 * @author wishmumu
 * @since 2023-03-11 15:42:55
 */
@Service
public class OmsOrderReturnReasonService {

    @Autowired
    private OmsOrderReturnReasonMapper returnReasonMapper;

    public CommonPage selectAll(Integer pageNum, Integer pageSize) {
        List<OmsOrderReturnReason> orderReturnReasons = returnReasonMapper.selectAll((pageNum-1)*pageSize, pageSize);
        Integer count = returnReasonMapper.selectCount();
        return new CommonPage(pageNum,pageSize,count,orderReturnReasons);
    }

    public OmsOrderReturnReason getById(Integer id) {
        return returnReasonMapper.selectById(id);
    }

    public void updateById(Integer id, OmsOrderReturnReason returnReason) {
        returnReasonMapper.updateById(id,returnReason);
    }

    public void updateStatus(ArrayList<Integer> ids, Integer status) {
        returnReasonMapper.updateStatus(ids,status);
    }

    public void save(OmsOrderReturnReason omsOrderReturnReason) {
        omsOrderReturnReason.setCreateTime(new Date(System.currentTimeMillis()));
        returnReasonMapper.insert(omsOrderReturnReason);
    }

    public void removeByIds(List<Integer> ids) {
        returnReasonMapper.deleteBatchIds(ids);
    }
}

